/*******************************************************************************
 File Name        : ringqueue.h
 Summary          : A ring queue with one thread read and one thread write
 Create           : 2023-03-24
 Author           : Schindleren
 Update history   :
 NO.     Author        Date         Content
 001     Schindleren   2023-03-24   Create New
*******************************************************************************/

#ifndef RINGQUEUE_H
#define RINGQUEUE_H

#include "freyabasedata.h"

class RingQueue
{
    enum F_QUEUE
    {
        F_EMPTY,
        F_FULL
    };

    struct RingQ
    {
        int head;
        int tail;
        F_QUEUE flag;
        int size;
        FreyaData *queue;

        RingQ(int q_size)
        {
            head = 0;
            tail = 0;
            flag = F_EMPTY;
            size = q_size;
            queue = new FreyaData[size];
        }

        ~RingQ()
        {
            delete []queue;
        }
    };

public:
    RingQueue(int q_size);

    bool push(FreyaData value);
    bool pull(FreyaData &value);

    int size();

    bool isEmpty();
    bool isFull();

private:
    RingQ       m_RingQ;
};

#endif // RINGQUEUE_H
